<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vuev2.5.21.js"></script>
</head>
<body>
  <script>
  var vm = new Vue({
  data: { a: 1 },
  computed: {
    // 仅读取
    aDouble: function () {
      return this.a * 2
    },
    //读取和设置
    aPlus: {
      get: function () {
        return this.a + 1
      },
      set: function (v) {
        this.a = v - 1
      }
    }
  }
})
console.log('====================================');
console.log(vm.aPlus);
console.log('====================================');   // => 2
console.log('====================================');
console.log(vm.aPlus = 3);
console.log('====================================');
console.log('====================================');
console.log(vm.a );
console.log('====================================');      // => 2
 console.log(vm.aDouble);
 
  </script>
</body>
</html>